import { defineStore } from "pinia";
import { ref } from "vue";
import { theme } from "@/theme.js";

export const useThemeStore = defineStore("theme", () => {
  //商务风
  const isBusiness = ref(false);

  //简约风
  const isSimple = ref(false);

  //暗黑模式
  const isDark = ref(false);

  //默认皮肤设置
  const currentSkin = ref({
    colorSuccess: "#52C41A",
    wireframe: true,
    colorPrimary: "#722ED1",
    colorWarning: "#FAAD14",
    colorError: "#F5222D",
    colorInfo: "#722ED1",
  });

  //当前主题色
  const currentThemeColor = ref({});

  //多页签
  const multiTabs = ref(true);

  //当前布局模式
  const currentLayout = ref("siderMode");

  //遍历主题皮肤，当切换时过滤当前皮肤
  const filterTheme = (item) => {
    for (let i = 0; i < theme.length; i++) {
      // 检查当前对象是否包含item键
      if (item in theme[i]) {
        // 如果找到，返回item对象
        currentSkin.value = theme[i][item];
      }
    }
  };

  return {
    isDark,
    currentSkin,
    filterTheme,
    isBusiness,
    isSimple,
    currentThemeColor,
    multiTabs,
    currentLayout,
  };
});
